FROM mindcollapse/malware-multi-scan-scanner:latest

ARG KES_KEY
ENV KES_KEY=$KES_KEY

ARG KES_URL=https://products.s.kaspersky-labs.com/endpoints/keslinux10/10.1.1.6421/multilanguage-10.1.1.6421/babce9ef/kesl_10.1.1-6421_amd64.deb
ENV KES_URL=$KES_URL

RUN apt-get update && apt-get install make gcc wget perl procps -y
RUN wget -q $KES_URL -O /tmp/kesl.deb && dpkg -i /tmp/kesl.deb && rm -f /tmp/kesl.deb

RUN printf "\
EULA_AGREED=yes \n\
PRIVACY_POLICY_AGREED=yes \n\
USE_KSN=yes \n\
UPDATER_SOURCE=KLServers \n\
PROXY_SERVER=none \n\
UPDATE_EXECUTE=yes \n\
IMPORT_SETTINGS=yes \n\
USE_GUI=no \n\
INSTALL_LICENSE=$KES_KEY\
" > /tmp/kesl_autoinstall

RUN /opt/kaspersky/kesl/bin/kesl-setup.pl --autoinstall=/tmp/kesl_autoinstall || exit 0

RUN printf '\
#!/bin/bash \n\
kesl-control --scan-file $1 > /dev/null \n\
kesl-control -B --query "FileName == \"$1\"" 2> /dev/null \n\
exit $? \
' > /usr/bin/kesl-scan && chmod +x /usr/bin/kesl-scan

ENV BackendType=Kes

ENTRYPOINT /etc/init.d/kesl-supervisor start && /worker/MalwareMultiScan.Scanner